Imports System.Data.OracleClient



Public Class clsCnst

  Public cmd_cnst As OracleCommand
  Public dr_cnst As OracleDataReader

  Public cnst_mcls_id As Integer
  Public cnst_name As String
  Public cnst_valu As String
  Public cnst_catg As String
  Public cnst_data_type As String




  Public Function select_CNST() As Boolean

    Dim str As String

    If cnst_mcls_id <> 0 Then
      str = "select * from TRDX_PP_CONSTANT where CNST_MCLS_IDXX = " & cnst_mcls_id
      cmd_cnst = New OracleCommand(str, con)
      dr_cnst = cmd_cnst.ExecuteReader
      select_CNST = True
    Else
      MessageBox.Show("Invalid Values", gCONST_MSG_HEADER, MessageBoxButtons.OK)
      select_CNST = False
    End If

  End Function




  Public Function insert_CNST() As Integer

    Dim lIntSeqNum As Integer
    Dim str As String

    cmd_cnst = New OracleCommand("select count(*) as CNT from TRDX_PP_CONSTANT", con)
    Dim nCount As Integer = cmd_cnst.ExecuteScalar()
    If nCount = 0 Then
      lIntSeqNum = 0
    Else
      cmd_cnst = New OracleCommand("select max(CNST_MCLS_IDXX) as CNT from TRDX_PP_CONSTANT", con)
      lIntSeqNum = cmd_cnst.ExecuteScalar
    End If
    str = "insert into TRDX_PP_CONSTANT values(" & (lIntSeqNum + 1) & ",'"
    str = str & cnst_name & "','" & cnst_valu & "','" & cnst_catg & "','" & cnst_data_type & "')"
    cmd_cnst = New OracleCommand(str, con)
    cmd_cnst.ExecuteNonQuery()
    insert_CNST = lIntSeqNum + 1

  End Function




  Public Function update_CNST() As Boolean

    Dim str As String

    cmd_cnst = New OracleCommand("select count(*) as CNT from TRDX_SUB_CLASS where SCLS_CLAS_IDXX = " & cnst_mcls_id, con)
    Dim ncount As Integer = cmd_cnst.ExecuteScalar
    If ncount <> 0 Then
      str = "update TRDX_PP_CONSTANT set CNST_CNST_NAME = '" & cnst_name & "',"
      str = str & "CNST_CNST_VALU = '" & cnst_valu & "',"
      str = str & "CNST_CNST_CATG = '" & cnst_catg & "',"
      str = str & "CNST_CNST_DATA_TYPE = '" & cnst_data_type & "'"
      str = str & " where CNST_MCLS_IDXX = " & cnst_mcls_id
      cmd_cnst = New OracleCommand(str, con)
      cmd_cnst.ExecuteNonQuery()
      update_CNST = True
    Else
      MessageBox.Show("Invalid values", gCONST_MSG_HEADER, MessageBoxButtons.OK)
      update_CNST = False
    End If
  End Function


  Public Function select_all_CNST() As Boolean

    cmd_cnst = New OracleCommand("select * from TRDX_PP_CONSTANT order by CNST_CNST_NAME", con)
    dr_cnst = cmd_cnst.ExecuteReader
    select_all_CNST = True

  End Function

End Class
